/*
该文件专门为Count组件生成action对象
*/
import {DECREMENT, INCREMENT} from "../constant";
import store from "../store";

//所谓同步action，就是值action的值是Object类型一般对象
export const createIncrementAction = data => ({type: INCREMENT, data})
export const createDecrementAction = data => ({type: DECREMENT, data})
//所谓异步action，就是值action的值是函数，异步action中一般都会调用同步的action，异步action不是必须要用的
export const createIncrementAsyncAction = (data, time) => {
    return () => {
        setTimeout(() => {
            store.dispatch(createIncrementAction(data))
        }, time)
    }
}